<template>
    <div>
        分类名<input type="text" v-model="name">
        图片<input type="file" @change="getpic">
        <button @click="Addcate">添加</button>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            pic:'',
            name:''
        }
    },
    methods: {
        Addcate(){
            let ca =new FormData()
            ca.append('name',this.name)
            ca.append('pic',this.pic)
            axios.post('http://127.0.0.1:8000/cate/',ca)
            .then(resp=>{
                alert('添加成功')
            })
        },
        getpic(e){
            this.pic=e.target.files[0]
        }
    },
    created() {

    }
}
</script>

<style scoped>

</style>
